<template>
  <div class="swiper">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="(item,index) in bgImgList" :key="index">
        <img :src="item.url" alt="">
      </div>
    </div>
  </div>
</template>

<script>
  import Swiper from "swiper/swiper-bundle.min.js"
  var mySwiper = new Swiper('.swiper',{
    effect : 'fade',
    fadeEffect: {
      crossFade: true,
    }
  })
  export default {
    name: "Carousel",
    data() {
      return {
        imgIndex: 0,
        bgImgList: [
          { url: require('../../../assets/login/bg1.jpg') },
          { url: require('../../../assets/login/bg2.jpg') },
          { url: require('../../../assets/login/bg3.jpg') },
          { url: require('../../../assets/login/bg4.jpg') },
          { url: require('../../../assets/login/bg5.jpg') }
        ],
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.setSwiper()
      })
    },
    methods: {
      setSwiper() {
        let my = new Swiper(".swiper", {
          autoplay: {
            delay: 5000,
            stopOnLastSlide: false,
            disableOnInteraction: false,
          },
          loop: true,  // 无限循环
          effect : 'fade',
          fadeEffect: {
            crossFade: true,
          },
          // pagination: {
          //   el: ".swiper",
          //   clickable :true,
          // },
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "~swiper/swiper-bundle.min.css";
  img{
    min-height: 100%;
    min-width: 100%;
  }
</style>
